package cn.tedu.spring.dibase;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * 需求 在UserService中注入UserDao对象
 */
@Service
public class UserService {
    @Value("业务名称:查看购物车")
    private String name;
    /*
        @Autowired 自动装配 注入对象或接口类型的数据
        添加位置 1 属性上
               2 set方法
               3 构造方法
     */
    @Autowired
    private UserDao userDao;
    //@Autowired//set方法
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }
    //@Autowired//构造方法
    public UserService(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public String toString() {
        return "UserService{" +
                "name='" + name + '\'' +
                ", userDao=" + userDao +
                '}';
    }
}
